Public Class LungResult

#Region "Fields"
    Protected _lung_result_id As Short
    Protected _lung_result_name_tha As String
    Protected _lung_result_name_eng As String
    Protected _Data As ArrayList
    Protected _DataCurrent As Integer
#End Region

#Region "Properties"
    Public Property lung_result_id() As Short
        Get
            Return _lung_result_id
        End Get
        Set(ByVal value As Short)
            _lung_result_id = value
        End Set
    End Property

    Public Property lung_result_name_tha() As String
        Get
            Return _lung_result_name_tha
        End Get
        Set(ByVal value As String)
            _lung_result_name_tha = value
        End Set
    End Property

    Public Property lung_result_name_eng() As String
        Get
            Return _lung_result_name_eng
        End Get
        Set(ByVal value As String)
            _lung_result_name_eng = value
        End Set
    End Property
#End Region

#Region "Methods"
    Public Function getLungResult() As DataSet
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_LungResult"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "LungResult")

        Return objDs
    End Function

    Protected Function getsLungResult() As ArrayList
        Dim outResult As New ArrayList()
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_LungResult"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "LungResult")

        For Each objDr As System.Data.DataRow In objDs.Tables("LungResult").Rows
            Dim obj As LungResult = New LungResult
            obj.lung_result_id = objDr.Item("lung_result_id")
            obj.lung_result_name_tha = Utilities.ClearDBNullToEmptyString(objDr.Item("lung_result_name_tha"))
            obj.lung_result_name_eng = objDr.Item("lung_result_name_eng")
            outResult.Add(obj)
        Next

        Return outResult
    End Function

    Public Sub LoadLungResult(ByVal inOrganizationID As String, ByVal inYear As String)
        _Data = New ArrayList
        _DataCurrent = 0
        _Data = getsLungResult()
    End Sub

    Public Function NextRecord() As Boolean
        If ((Not _Data Is Nothing) AndAlso (((Not _Data Is Nothing) AndAlso _
            (_DataCurrent < _Data.Count And _Data.Count > 0)))) Then
            _lung_result_id = _Data(_DataCurrent).lung_result_id
            _lung_result_name_tha = _Data(_DataCurrent).lung_result_name_tha
            _lung_result_name_eng = _Data(_DataCurrent).lung_result_name_eng
            _DataCurrent += 1
            Return True
        End If
        Return False
    End Function

    Public Function getLungResultByEngName(ByVal inLungResultNameEng As String) As LungResult
        Dim outResult As New LungResult()
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_LungResultByEngName"

        Dim objParam As New MySql.Data.MySqlClient.MySqlParameter("inLungResultNameEng", inLungResultNameEng)
        objCmd.Parameters.Add(objParam)

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "LungResult")

        For Each objDr As System.Data.DataRow In objDs.Tables("LungResult").Rows
            outResult.lung_result_id = objDr.Item("lung_result_id")
            outResult.lung_result_name_tha = Utilities.ClearDBNullToEmptyString(objDr.Item("lung_result_name_tha"))
            outResult.lung_result_name_eng = objDr.Item("lung_result_name_eng")
        Next

        Return outResult
    End Function
#End Region

End Class
